package com.graduationproject.examonline.master.controller;

import com.graduationproject.examonline.master.service.MasterService;
import com.graduationproject.examonline.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("api/master")
public class MasterController {

    @Autowired
    private MasterService masterService;

    @GetMapping("/login")
    public Object login(String master_id, String master_password) {
        return masterService.login(master_id, master_password);
    }

    /**
     * @param params JSON包含token, master_id, next_master_id, next_master_password
     */
    @PostMapping("/update")
    public Result update(@RequestBody Map<String, Object> params) {
        return masterService.update(params);
    }

    @GetMapping("/getUserInfo")
    public Result getUserInfo(String master_id) {
        return masterService.getUserInfo(master_id);
    }

    @PostMapping("/updateName")
    public Result updateName(@RequestBody Map<String, Object> p) {
        return masterService.updateName(p);
    }

    @PostMapping("/updatePassword")
    public Result updatePassword(@RequestBody Map<String, Object> p) {
        return masterService.updatePassword(p);
    }
}
